package com.kernel.net;

import java.io.IOException;
import java.net.InetAddress;

/****************************************
 * @name InetAddress
 * @description
 * @author 黄彬恒
 * @since 2018/8/23
 ***************************************/
public class InetAddressDemo {
    public static void main(String[] args) {
        InetAddress locAdd;
        InetAddress remAdd;
        try {
            locAdd = InetAddress.getLocalHost();// 得到本机
            remAdd = InetAddress.getByName("www.baidu.com");// 得到远程
            System.out.println(locAdd.getHostAddress());
            System.out.println(remAdd.getHostAddress());
            System.out.println(locAdd.isReachable(100));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
